﻿// =================================================================== 
// 项目说明
//====================================================================
// lsc。@Copy Right 2019
// 文件： WeChartUser.cs
// 项目名称：斑马车务
// 创建时间：2019-07-31
// 负责人：lsc
// ===================================================================
using System;
using System.Data;
using System.Collections.Generic;
using Dapper.Extensions;
using YouWei.Infrastructure.Entity;
using YouWei.Infrastructure.Repository;
using YouWei.Infrastructure.Models;

namespace YouWei.Infrastructure.Service
{

    /// <summary>
    ///微信用户信息表
    /// </summary>
    public class WeChartUserService
    {
        protected WeChartUserRepository repository;

        public WeChartUserService()
        {
            repository = new WeChartUserRepository();
        }

        #region 增删改查

        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public object Insert(WeChartUser entity) { return repository.Insert(entity); }

        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public object Insert(List<WeChartUser> entitys) { return repository.Insert(entitys); }

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public bool Update(WeChartUser entity) { return repository.Update(entity); }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public bool Delete(WeChartUser entity) { return repository.Delete(entity); }

        /// <summary>
        /// 删除所有
        /// </summary>
        /// <returns></returns>
        public bool DeleteAll() { return repository.DeleteAll(); }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="primaryKey">主键</param>
        /// <returns></returns>
        public bool Delete(int primaryKey) { return repository.Delete(primaryKey); }

        /// <summary>
        /// 查询单个实体
        /// </summary>
        /// <param name="primaryKey">主键</param>
        /// <returns></returns>
        public WeChartUser SingleOrDefault(object primaryKey) { return repository.SingleOrDefault(primaryKey); }


        /// <summary>
        /// 查询单个实体,如果存在多条则引发异常
        /// </summary>
        /// <param name="primaryKey">主键</param>
        /// <returns></returns>
        public WeChartUser Single(object primaryKey) { return repository.Single(primaryKey); }

        /// <summary>
        /// 查询所有
        /// </summary>
        /// <returns></returns>
        public List<WeChartUser> QueryAll()
        {
            return repository.QueryAll();
        }

        #endregion



        /// <summary>
        /// 跟进OpenID查询
        /// </summary>
        /// <param name="openid"></param>
        /// <returns></returns>
        public WeChartUser GetByOpenID(string openid)
        {
            return repository.GetByOpenID(openid);
        }

        /// <summary>
        /// 跟进UnionID查询
        /// </summary>
        /// <param name="unionid"></param>
        /// <returns></returns>
        public List<WeChartUser> GetByUnionID(string unionid)
        {
            return repository.GetByUnionID(unionid);
        }


        /// <summary>
        /// 查询列表
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public Page<WeChartUser> Pages(int pageIndex, int pageSize, WechatUserSearchModel model)
        {
            return repository.Pages(pageIndex,pageSize,model);
        }
	
    }

}